package com.rabbitmq.dead;

import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Channel;
import com.rabbitmq.util.ConnectionUtils;

import java.io.IOException;
import java.util.Scanner;

/**
 * @author yinxing
 * @date 2022-08-30
 * <p>
 * 生产者代码
 */
public class Producer {

    private final static String NORMAL_EXCHANGE = "normal_exchange";

    private final static String NORMAL_ROUTE_KEY = "normal_key";

    private final static String NORMAL_QUEUE_NAME = "normal_queue";

    public static void main(String[] args) throws IOException {
        Channel channel = ConnectionUtils.getChannel();
        Scanner scanner = new Scanner(System.in);
        AMQP.BasicProperties props =
                new AMQP.BasicProperties().builder().expiration("10000").build();
        while (scanner.hasNext()) {
            String message = scanner.next();
            System.out.println("发送消息:" + message);
            channel.basicPublish(NORMAL_EXCHANGE, NORMAL_ROUTE_KEY, props,message.getBytes());
        }
    }
}
